package 笔试.微众;

import java.util.Arrays;

/**
 * @author:谢君臣
 * @Date:2021/8/28-20:38
 * @version:1.0
 * @function:
 */
public class 小鸡进食 {
    public static void main(String[] args) {
        System.out.println(find(new int[]{1, 3, 2, 3, 5, 9, 2, 3, 6}));
    }

    private static int find(int[] arr) {
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        int i = 0;
        for (int j = 0; j < arr.length; j++) {
            while (i< arr.length&&arr[i]<j+1)i++;
            if (i>= arr.length)return j+1;
            else i++;
        }
        return arr.length;
    }
}
